// Errorm.cpp
//
//  Handling errors
//    * critical errors (INT24)
//    * in-game fatal errors (no memory, internal errors, etc.)
//
#include "stdafx.h"
#include "errorm.h"
#include <stdio.h>            // printf()
#include <stdarg.h>           // va_list, va_arg, ...
#include <stdlib.h>           // exec()
#include <dos.h>              // _harderr()


//------------------------------------------------------------------------
//
//    In-game fatal errors (no memory, internal errors, etc.)
//
//------------------------------------------------------------------------
//extern void ShutDown(void);

//#if WIN_VERSION == 0

void printfERROR(char *fmt, ...) {
  flushall();
//  ShutDown();
  va_list    parg;
  va_start(parg,fmt);
  printf("\n\n");
  vprintf(fmt,parg);
  printf("\n");
  va_end(parg);
  flushall();
  exit(1);
}

void _cdecl ERROR(char *fmt, ...) {
  flushall();
//  ShutDown();
  va_list    parg;
  va_start(parg,fmt);
  printf("\n** ERROR: **\n");
  vprintf(fmt,parg);
  printf("\n");
  va_end(parg);
  flushall();
  exit(1);
}

void InternalERROR(char *fmt, ...) {
  flushall();
//  ShutDown();
  va_list    parg;
  va_start(parg,fmt);
  printf("\n** INTERNAL ERROR: **\n");
  vprintf(fmt,parg);
  printf("\n");
  va_end(parg);
  flushall();
  exit(1);
}

void NoMemoryERROR(char *fmt, ...) {
  flushall();
//  ShutDown();
  va_list    parg;
  va_start(parg,fmt);
  printf("\n** NOT ENOUGH MEMORY: **\n");
  vprintf(fmt,parg);
  printf("\n");
  va_end(parg);
  flushall();
  exit(1);
}

//#endif
//------------------------------------------------------------------------
// End: In-game fatal errors (no memory, internal errors, etc.)
//------------------------------------------------------------------------



//void SetCriticalErrorHandler(void) {
//#if WIN_VERSION == 0
//  _harderr(critical_error_handler);
//#endif
//}
//------------------------------------------------------------------------
// End:  Critical errors (INT24)
//------------------------------------------------------------------------

/* eof */
